setwd("E:/5hmc_file/2_5hmc_yjp_bam/ASM/")
file=read.csv("20201120/at.least.one.AShM.in.DC.add.BF.beta0.add.CCHC.csv",head=T)
file1=file[file$pattern.not.rm.dupl.num.DC>1,]
file2=file1[file1$BF_in_DC>1,]
file3=file1[file1$BF_in_DC>10,]
col_names=c("FileName","weak ASH","strong ASH","weak psH","strong psyASH")
result=data.frame(matrix(NA,1,ncol = 5))
names(result)=col_names
result=result[-1,]


cn=names(file)
sel=cn[grep(cn,pattern = "BayesFactor")][1:6]
test=file[,sel]
test1=file1[,sel]
test2=file2[,sel]
test3=file3[,sel]
i=1
for(i in 1:6){
  result_tmp=data.frame(matrix(NA,1,ncol = 5))
  names(result_tmp)=col_names
  
  lis=test[,i]
  lis=lis[!is.na(lis)]
  lis1=test1[,i]
  lis1=lis1[!is.na(lis1)]
  lis2=test2[,i]
  lis2=lis2[!is.na(lis2)]
  lis3=test3[,i]
  lis3=lis3[!is.na(lis3)]
  
  result_tmp[,1]=gsub(".BayesFactor","",names(test)[i])
  result_tmp[,2]=length(lis)
  result_tmp[,3]=length(lis1)
  result_tmp[,4]=length(lis2)
  result_tmp[,5]=length(lis3)
  result=rbind(result,result_tmp)
}
write.csv(result,"DC.varscan.log.csv",quote=F,row.names = F)

###以下代码是统计CC和HC中strong ASH的，没写完
test=file[file$CC.FDR.sig>0,]
cn=names(filea)
sel=cn[grep(cn,pattern = "BayesFactor")][7:10]
test=file[,sel]
test1=file1[,sel]
test2=file2[,sel]
test3=file3[,sel]
i=1
for(i in 1:4){
  result_tmp=data.frame(matrix(NA,1,ncol = 3))
  names(result_tmp)=col_names
  
  lis=test[,i]
  lis=lis[!is.na(lis)]
  lis1=test1[,i]
  lis1=lis1[!is.na(lis1)]
  lis2=test2[,i]
  lis2=lis2[!is.na(lis2)]
  lis3=test3[,i]
  lis3=lis3[!is.na(lis3)]
  
  result_tmp[,1]=gsub(".BayesFactor","",names(test)[i])
  result_tmp[,2]=length(lis)
  result_tmp[,3]=length(lis1)
  result_tmp[,4]=length(lis2)
  result_tmp[,5]=length(lis3)
  result=rbind(result,result_tmp)
}
write.csv(result,"CC.varscan.log.csv",quote=F,row.names = F)

